//
//  BasicTool.swift
//  AsyncAwait
//
//  Created by admin on 2021/10/28.
//

import Foundation
import UIKit


class BasicTool {
    public class func currentViewController() -> UIViewController? {
        let keyWindow = UIApplication.shared.keyWindow
         var vc = keyWindow?.rootViewController
         let runLoopFind = true
         while runLoopFind {
             if ((vc?.presentedViewController) != nil) {
                 vc = vc?.presentedViewController
             }else if let nav = vc?.isKind(of: UINavigationController.self), nav {
                 vc = (vc as? UINavigationController)?.visibleViewController
             }else if let tab = vc?.isKind(of: UITabBarController.self), tab{
                 vc = (vc as? UITabBarController)?.selectedViewController
             }else {
                 break
             }
         }
         return vc
     }
}


